package com.mrd.gtimpframe.service.impl;

import com.mrd.gtimpframe.entity.ComDeclaWay;
import com.mrd.gtimpframe.repository.ComDeclaWayMapper;
import com.mrd.gtimpframe.service.ComDeclaWayService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by dusy on 2017/10/26.
 */
@Service
public class ComDeclaWayServiceImpl implements ComDeclaWayService {
    @Autowired
    private ComDeclaWayMapper comDeclaWayMapper;

    @Override
    public int deleteByPrimaryKey(String id) {
        return comDeclaWayMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(ComDeclaWay record) {
        return comDeclaWayMapper.insert(record);
    }

    @Override
    public int insertSelective(ComDeclaWay record) {
        return comDeclaWayMapper.insertSelective(record);
    }

    @Override
    public ComDeclaWay selectByPrimaryKey(String id) {
        return comDeclaWayMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ComDeclaWay> selective(ComDeclaWay record) {
        return comDeclaWayMapper.selective(record);
    }

    @Override
    public int updateByPrimaryKeySelective(ComDeclaWay record) {
        return comDeclaWayMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(ComDeclaWay record) {
        return comDeclaWayMapper.updateByPrimaryKey(record);
    }

    /**
     * 根据上传渠道代码获取公司id
     */
    @Override
    public List<String> selectComIds(String wayCode) {
        return comDeclaWayMapper.selectComIds(wayCode);
    }

    /**
     * 查公司对应单一窗口配置
     */
    @Override
    public ComDeclaWay findByComId(String comId) {
        ComDeclaWay query = new ComDeclaWay();
        query.setStatus("1");
        query.setComId(comId);
        query.setWayCode(ComDeclaWay.WayCodeEnum.COM_PORT_FTP.toString());
        List<ComDeclaWay> queryResults = comDeclaWayMapper.selective(query);
        if (queryResults == null) {
            return null;
        }
        return queryResults.get(0);
    }
}
